package com.pxxy.mall.product.exception;

import com.pxxy.common.exception.BizCodeEnum;
import com.pxxy.common.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author zhangjj
 * @since 2023/12/21
 */
@Slf4j
@RestControllerAdvice(basePackages= "com.pxxy.mall.product")
public class mallExceptionController {

    @ExceptionHandler(Exception.class)
    public R handleValidException(Exception e) {

        return R.error(BizCodeEnum.VALID_EXCEPTION.getCode(), BizCodeEnum.VALID_EXCEPTION.getMsg());

    }

    @ExceptionHandler(Throwable.class)
    public R handleException(Throwable e) {
        return R.error(BizCodeEnum.UNKNOW_EXCEPTION.getCode(), BizCodeEnum.UNKNOW_EXCEPTION.getMsg());
    }


}
